#pragma once
#include <iostream>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

class InetAddr
{
private:
    void Init()
    {
        _IP=inet_ntoa(_addr.sin_addr);
        _port=ntohs(_addr.sin_port);
    }
public:
    InetAddr(struct sockaddr_in addr) : _addr(addr)
    {
        Init();
    }
    std::string IP()
    {
        return _IP;
    }
    uint16_t port()
    {
        return _port;
    }
private:
    struct sockaddr_in _addr;
    std::string _IP;
    uint16_t _port;
};